package control;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.mysql.cj.conf.ConnectionUrlParser.Pair;

import entity.CommentVO;
import entity.Remark;
import entity.Zremark;
import service.CommentService;
import service.CommentServiceimpl;


public class Getcomment  extends HttpServlet{


	CommentService csc = new CommentServiceimpl();


	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
////        List<Pair<CommentVO,List<Zremark>>> lst = new ArrayList<Pair<CommentVO,List<Zremark>>>();
//		List<Pair<CommentVO,List<Zremark>>> lst = new ArrayList<Pair<CommentVO,List<Zremark>>>();
//		Map<CommentVO,List<Zremark>> mp = new TreeMap<CommentVO, List<Zremark>>();
//		
//		List<Zremark> ls1,ls2;
//		CommentVO co,co1;
//		Zremark zk,zk1;
//		zk=new Zremark(1,2,"45@.cm","???akls;djasjdjasjdl;","DFSF");
//		zk1=new Zremark(9,6,"469@.cm","dsadddddddddjasjdl;","SDFSD");
//		co= new CommentVO(21,"469@sss.cm","helllo","aklsdhsadnhalk",null,null,20,100);
//		co1= new CommentVO(91,"ssss9@sss.cm","bagao",null,"354344alk",null,9999,5000);
//		ls1 =  new ArrayList<Zremark>();
//		ls1.add(zk);
//		ls1.add(zk1);
//		ls2 =  new ArrayList<Zremark>();
//		ls2.add(zk);
//		ls2.add(zk1);
//
//		Pair<CommentVO,List<Zremark>> p1 = new Pair<CommentVO, List<Zremark>>(co,ls1);
//		Pair<CommentVO,List<Zremark>> p2 = new Pair<CommentVO, List<Zremark>>(co1,ls2);
//
//		lst.add(p1);
//		lst.add(p2);
		resp.setCharacterEncoding("utf-8");
		String wordname = req.getParameter("wordname");
		System.out.println(wordname);
		List<Pair<CommentVO, List<Zremark>>> lst = null;
		try {
			lst = csc.getremark(wordname);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		resp.getWriter().print(JSON.toJSON(lst));
		
		
	}
	
	

}
